[?php use_helper('SEstadisticas') ?]
[?php echo_title('Comparar') ?]
<div id="admin_container">

  <h1>Comparar versiones de <?php echo $this->getReadableName() ?></h1>

  <div id="admin_content">
    <div id="admin_show">
      <table class="compare_table">
        <thead>
          <tr>
            <th style="width: 20%"></th>
            <th style="width: 40%">Versión actual ([?php echo $current['version'] ?])</th>
            <th style="width: 40%">Versión previa ([?php echo $previous['version'] ?])</th>
          </tr>
        </thead>
        <tbody>
<?php $index = 0 ?>
        [?php $default = $configuration->getFieldsDefault() ?]
<?php foreach ($this->configuration->getFieldsCompare() as $field): ?>
<?php if ($field == 'id' || $field == 'version') continue ?>
          <tr class="<?php echo $index++ % 2 == 0 ? 'even' : 'odd' ?>">
            <td class="admin_show_name">
              [?php echo $helper->getFieldLabel('<?php echo $field ?>', isset($default['<?php echo $field ?>']) ? $default['<?php echo $field ?>'] : null) ?]
            </td>
<?php if ($this->table->getTypeOf($field) === false): ?>
              [?php echo diff_simple($current-><?php echo $this->getColumnGetter($field) ?>()->__toString(), $previous-><?php echo $this->getColumnGetter($field) ?>()->__toString()) ?]
<?php else: ?>
              [?php echo diff($helper->getFieldValue($current-><?php echo $this->getColumnGetter($field) ?>(), $default['<?php echo $field ?>']), $helper->getFieldValue($previous-><?php echo $this->getColumnGetter($field) ?>(), $default['<?php echo $field ?>'])) ?]
<?php endif ?>
          </tr>
<?php endforeach ?>
<?php if ($this->table->hasTemplate('Auditable')): ?>
<?php foreach ($this->table->getTemplate('Auditable')->getOption('relations') as $relation): ?>
          <tr class="<?php echo $index++ % 2 == 0 ? 'even' : 'odd' ?>">
            <td class="admin_show_name">
              [?php echo $helper->getFieldLabel('<?php echo $relation ?>', isset($default['<?php echo $relation ?>']) ? $default['<?php echo $relation ?>'] : null) ?]
            </td>
              [?php include_partial('<?php echo $this->getModuleName() ?>/compare_relations', array('current' => $current_relations['<?php echo $relation ?>'], 'previous' => $previous_relations['<?php echo $relation ?>'])) ?]
          </tr>
<?php endforeach ?>
<?php endif ?>
        </tbody>
      </table>
    </div>
    <ul class="admin_actions">
      [?php echo $helper->linkToHistoric($current) ?]
    </ul>
  </div>
</div>
